/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ua.yandex.skipass;

import java.util.Calendar;

/**
 *
 * @author Neophron
 */
public class SeasonPass implements Pass {

    private static final PassType TYPE = PassType.SEASON;

    private final int id;

    private final Seasons workSeason;

    private SeasonPass(int id, Seasons workSeason) {
        this.id = id;
        this.workSeason = workSeason;
    }

    @Override
    public int getId() {
        return id;
    }

    @Override
    public PassType getType() {
        return TYPE;
    }

    @Override
    public boolean allowTrip(Calendar curDay) {
        int curMonth = curDay.get(Calendar.MONTH);
        switch (workSeason) {
            case WINTER:
                return curMonth == Calendar.JANUARY || curMonth
                        == Calendar.FEBRUARY
                        || curMonth == Calendar.DECEMBER;
            case SPRING:
                return curMonth >= Calendar.MARCH && curMonth <= Calendar.MAY;
            case SUMMER:
                return curMonth >= Calendar.JUNE && curMonth
                        <= Calendar.AUGUST;
            case AUTUMN:
                return curMonth >= Calendar.SEPTEMBER && curMonth 
                        <= Calendar.NOVEMBER;
            default:
                return false;
        }
    }

    public static SeasonPass createSeasonPass(int id, Seasons season) {
        return new SeasonPass(id, season);
    }
}
